import { createApp } from 'vue'
// import './style.css'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import request from "./utils/request";
import api from './api'
import store from "./store";
import * as ElIcons from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import storage from "./utils/storage";
import "default-passive-events"
import YYComp from '../packages'
// console.log('env', import.meta.env)

const app = createApp(App)

app.directive('auth', {
    beforeMount: (el, binding) => {
        let actionList = storage.getItem('actionList')
        let value = binding.value
        let hasPermission = actionList.includes(value)
        if (!hasPermission) {
            el.style = 'display: none'
            setTimeout(() => {
                el.parentNode.removeChild(el)
            },0)
        }
    }
})

for (const name in ElIcons){
    app.component(name, ElIcons[name])
}
app.config.globalProperties.$request = request
app.config.globalProperties.$api = api
app.use(ElementPlus, {size: 'default', locale: zhCn})
    .use(router)
    .use(store)
    .use(YYComp)
    .mount('#app')
